package org.bbs.demo.user.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.bbs.demo.user.dto.UserSignupDto;

import java.sql.Date;

@Mapper
public interface UserSignupDao {

    // 查找邮箱是否注册
    @Select("select COUNT(user_id) from bbsusers where mail = #{mail}")
    public int findUserByEmail(UserSignupDto userSignupDto);

    // 查找最大的uid
    @Select("select MAX(user_id) from bbsusers")
    public String findMaxUid();

    // 注册新用户
    @Insert("insert into bbsusers(user_id, u_name, password, birth, sex, mail, school, major, phone) " +
            "values (#{user_id}, #{u_name}, #{password}, #{birth}, #{sex}, #{mail}, #{school}, #{major}, #{phone})")
    public int userSignup(UserSignupDto userSignupDto);
}